ALMaSS  1.0
The Animal, Landscape and Man Simulation System
VolePopulationManager.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
39 //---------------------------------------------------------------------------
40 
41 #ifndef VolePopulationManagerH
42 #define VolePopulationManagerH
43 
44 //---------------------------------------------------------------------------
45 
46 class struct_Vole_Adult;
47 class TAnimal;
48 class Vole_Male;
49 class Vole_Female;
50 class AlleleFreq1616;
51 class AlleleFreq;
52 class APoint;
53 
54 //------------------------------------------------------------------------------
55 
56 typedef vector < Vole_Male* > Vole_MaleList;
57 typedef vector < Vole_Female* > Vole_FemaleList;
58 
59 
64 typedef enum {
67 
72 typedef enum {
88 
89 
95 {
96 public:
98  TrapLineMap( unsigned int a_width, unsigned int a_height, unsigned int a_resolution, const char* a_file );
100  ~TrapLineMap();
102  bool IsTrap(unsigned a_x, unsigned a_y) {
103  if (GetValue( a_x, a_y ) == 1) return true;
104  return false;
105  };
106  void Output(InTrapPosition a_tp, int a_day, int a_sex, bool a_terr, int a_age, int a_bx, int a_by, int a_ID );
107 protected:
109  void Init( const char* a_inifile );
111  unsigned m_noTraps;
113  vector < APoint > m_TrapCoords;
114  FILE* m_ofile;
115 };
116 
117 
123 {
124 public:
125  VoleSummaryOutput(const char* a_filename, Landscape* a_land, int a_numdataINT, int a_numdataDOUBLE);
126  virtual~VoleSummaryOutput();
127  virtual void OPrint();
128  virtual void OPrint(int a_value);
129  virtual void OPrint(double a_value);
130  virtual void OPrint(const char* a_value);
131  virtual void OPrintEndl();
132  void ResetData();
133  void ChangeData(int a_data, int a_value);
134  void ChangeData(int a_data, double a_value);
135 protected:
136  ofstream* m_File;
138  int m_ndInt;
140  int m_dataI[100]; // This is way more than we should ever need
141  double m_dataD[100]; // This is way more than we should ever need
142  void OpenOutput( const char* a_filename );
143  void CloseOutput();
144 
145 };
146 
152 {
153  protected:
154 
156  void DoFirst();
157  virtual void Catastrophe();
159  int m_male1;
161  int m_total1;
162 
163  int m_male2;
165  int m_total2;
166 
167  int m_male3;
169  int m_total3;
170  //double m_BaseVoleDensity;
172  vector<double> VoleHabitatBaseQualities;
173  bool OpenSexRatiosProbe();
174  void CloseSexRatiosProbe();
175  bool SuitableStartingLocation(int a_x, int a_y);
176  double AssessHabitat(int p_Polyref);
177 
178 #ifdef __VOLEPESTICIDEON
179 public:
180  void AddToImpacted() {m_impacted++;}
181  void AddToNotImpacted() {m_notimpacted++;}
182  void AddToGeneticImpacted() {m_geneticimpacted++;}
183  void incLittersLost() { m_LittersLost++; }
184  void incLittersProduced() { m_LittersProduced++; }
185 protected:
186  int m_impacted; // counter for voles hit and affected by pesticide
187  int m_notimpacted; // counter for voles not hit and affected by pesticide
188  int m_geneticimpacted; // counter for voles not hit and affected by pesticide
189  double m_geneticsterilitychance;
190  double m_f1sterilitychance;
191  int m_LittersLost;
192  int m_LittersProduced;
193 #endif
196  public:
198  FILE * SexRatiosPrb;
200  uint32 GetVoleAllele(int a_list, int a_vole, int a_locus, int a_chromosome)
201  {
202  Vole_Base* new_VB;
203  new_VB = dynamic_cast<Vole_Base *>(TheArray[a_list][a_vole]);
204  return new_VB->SupplyMyAllele(a_locus, a_chromosome);
205  }
206  virtual void ImpactedProbe( );
207  bool IsTrap(int p_x, int p_y) { m_TheLandscape->CorrectCoords(p_x,p_y); return m_Traplines->IsTrap(p_x, p_y); };
208  //virtual void Catastrophe(int a_mort);
209  void TheAgeSexLocationProbe();
210  virtual void TheAOROutputProbe();
211  virtual void TheRipleysOutputProbe(FILE* a_prb);
212  virtual void TheReallyBigOutputProbe();
213  virtual void TheSexRatiosProbe();
214  virtual void LandscapeQuadrantOutputProbe(int a_day);
215  void AddToFrag1Male() {m_male1++;} // ***TD***
221  int ReproTable [4][12]; // Filled in by init function
222  unsigned IDNumber;
228  virtual ~Vole_Population_Manager();
229  void CreateObjects(VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult* as,int number);
230  void CreateObjects_Init(VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult* as,int number);
231  virtual void Init (void);
232  bool RecordGeneticsToday(int p_today, int p_year, int p_start_year, int p_interval);
233  double GetHabitatQuality(int a_index) { return VoleHabitatBaseQualities[a_index]; }
234  bool SupplyOlderFemales(unsigned p_x, unsigned p_y, unsigned p_Age,
235  unsigned p_range);
236  int SupplyHowManyVoles(unsigned p_x, unsigned p_y, unsigned p_size);
238  int SupplyInOlderTerr(unsigned p_x, unsigned p_y,
239  unsigned p_Age, unsigned p_Range);
240  int SupplyCountFemales(unsigned p_x, unsigned p_y, unsigned p_TerrRange);
241  void SendMessage(TTypeOfVoleMessage p_message,unsigned p_x, unsigned p_y,
242  unsigned p_range, bool p_sex, double p_Weight /*, unsigned p_IDNo*/ );
243  vector<Vole_Base*>* SupplyVoleList(unsigned x, unsigned y, unsigned range);
244  bool InSquare(int p_x, int p_y,int p_sqx,int p_sqy, int p_range);
245  int ListClosestFemales(int p_x, int p_y, int p_steps);
246  int ListClosestMales(int p_x, int p_y, int p_steps);
247  Vole_Female* FindClosestFemale(int p_x, int p_y, int p_steps);
248  Vole_Male* FindClosestMale(int p_x, int p_y, int p_steps);
250  void AddToYoung(int young) {YoungProducedToday+=young;}
251  Vole_Male* FindWithinRadiusMale(int p_x, int p_y);
252  Vole_Male* FindOutsideRadiusMale(int p_x, int p_y); // ***TD***
253  bool BarrierSearch(int F_x, int F_y, int M_x, int M_y); // ***TD***
254  void AddToYoungYr(int young) {YoungProducedToday+=young;}
255  void AddToJuvs(int juvs) {JuvsProducedToday+=juvs;}
256  void AddToNoYoungInfanticideCount (int m_NoOfYoung, int m_YoungAge) { // ***TD***
257  NoYoungKilledToday+=m_NoOfYoung;
258  if (m_YoungAge<5) {
259  NoYoungKilledToday4+=m_NoOfYoung;
260  }
261  else if (m_YoungAge<9){
262  NoYoungKilledToday8+=m_NoOfYoung;
263  }
264  else {NoYoungKilledToday9+=m_NoOfYoung; }
265  }
266  void ReproductionProbe();
267  /* THIS FUNCTION IS OUTDATED; BUT MAYBE A REPLACEMENT IS NEEDED!!
268  void TheGeneticProbe(unsigned listindex,int ProbeNo,unsigned &SubSize);
269  */
270  void GeneticsOutputFile(unsigned listindex);
271  virtual void GeneticsResultsOutput(FILE* ofile,unsigned listindex);
273  void OpenResistanceOutput();
275  void CloseResistanceOutput();
277  void ResistanceOutput();
278 
279 // Attributes
283  FILE* YoungsFile;
286 
287 };
288 
289 //------------------------------------------------------------------------------
290 #endif
unsigned int uint32
Definition: ALMaSS_Setup.h:34
TTypeOfVoleMessage
Types of vole message.
Definition: VolePopulationManager.h:64
@ tovm_Infanticide
Definition: VolePopulationManager.h:65
vector< Vole_Female * > Vole_FemaleList
Definition: VolePopulationManager.h:57
TTypeOfVoleMortality
Types of vole mortality.
Definition: VolePopulationManager.h:72
@ tovmort_MPred
Definition: VolePopulationManager.h:81
@ tovmort_FDisp
Definition: VolePopulationManager.h:80
@ tovmort_FStarve
Definition: VolePopulationManager.h:74
@ tovmort_MPest
Definition: VolePopulationManager.h:85
@ tovmort_MLife
Definition: VolePopulationManager.h:83
@ tovmort_MStarve
Definition: VolePopulationManager.h:73
@ tovmort_FPest
Definition: VolePopulationManager.h:86
@ tovmort_FPred
Definition: VolePopulationManager.h:82
@ tovmort_FFarm
Definition: VolePopulationManager.h:78
@ tovmort_FLife
Definition: VolePopulationManager.h:84
@ tovmort_MBck
Definition: VolePopulationManager.h:75
@ tovmort_MFarm
Definition: VolePopulationManager.h:77
@ tovmort_FBck
Definition: VolePopulationManager.h:76
@ tovmort_MDisp
Definition: VolePopulationManager.h:79
vector< Vole_Male * > Vole_MaleList
Definition: VolePopulationManager.h:52
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:53
Definition: GeneticMaterial.h:126
Class to handle statistics and constructs based on allele frequencies.
Definition: GeneticMaterial.h:62
Definition: BinaryMapBase.h:29
uint64 GetValue(unsigned a_x, unsigned a_y)
Definition: BinaryMapBase.cpp:79
A class for storing the position of the trap the vole is in.
Definition: vole_all.h:113
The landscape class containing all environmental and topographical data.
Definition: landscape.h:113
void CorrectCoords(int &x, int &y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1535
Base class for all population managers.
Definition: PopulationManager.h:424
vector< TListOfAnimals > TheArray
Definition: PopulationManager.h:534
Landscape * m_TheLandscape
Definition: PopulationManager.h:515
The base class for all ALMaSS animal classes.
Definition: PopulationManager.h:205
A class for simulation virtual traplines.
Definition: VolePopulationManager.h:95
unsigned m_noTraps
The total number of traps.
Definition: VolePopulationManager.h:111
bool IsTrap(unsigned a_x, unsigned a_y)
Is there a trap at this x,y?
Definition: VolePopulationManager.h:102
void Output(InTrapPosition a_tp, int a_day, int a_sex, bool a_terr, int a_age, int a_bx, int a_by, int a_ID)
Definition: VolePopulationManager.cpp:3989
vector< APoint > m_TrapCoords
List of trap co-ordinates.
Definition: VolePopulationManager.h:113
TrapLineMap(unsigned int a_width, unsigned int a_height, unsigned int a_resolution, const char *a_file)
TrapLineMap constructor.
Definition: VolePopulationManager.cpp:3945
FILE * m_ofile
Definition: VolePopulationManager.h:114
~TrapLineMap()
TrapLineMap destructor.
Definition: VolePopulationManager.cpp:3950
void Init(const char *a_inifile)
Reads in the trap coords, creates the map and sets up the output files.
Definition: VolePopulationManager.cpp:3959
Base class for voles - all vole objects are descended from this class.
Definition: vole_all.h:153
uint32 SupplyMyAllele(int i, int j)
Definition: vole_all.h:387
The class for female voles.
Definition: vole_all.h:571
The class for male voles.
Definition: vole_all.h:493
The class to handle all vole population related matters.
Definition: VolePopulationManager.h:152
virtual ~Vole_Population_Manager()
Definition: VolePopulationManager.cpp:218
void AddToNoYoungInfanticideCount(int m_NoOfYoung, int m_YoungAge)
Definition: VolePopulationManager.h:256
int m_male3
Definition: VolePopulationManager.h:167
unsigned IDNumber
Definition: VolePopulationManager.h:222
double AssessHabitat(int p_Polyref)
Assess the quality of habitat at p_Polyref.
Definition: VolePopulationManager.cpp:771
void AddToFrag2Female()
Definition: VolePopulationManager.h:218
int SupplyInOlderTerr(unsigned p_x, unsigned p_y, unsigned p_Age, unsigned p_Range)
Definition: VolePopulationManager.cpp:3043
double GetHabitatQuality(int a_index)
Definition: VolePopulationManager.h:233
Vole_Male * FindOutsideRadiusMale(int p_x, int p_y)
Definition: VolePopulationManager.cpp:2399
int SupplyCountFemales(unsigned p_x, unsigned p_y, unsigned p_TerrRange)
Definition: VolePopulationManager.cpp:2897
IDMap< TAnimal * > * m_VoleMap
Definition: VolePopulationManager.h:284
int m_total3
Definition: VolePopulationManager.h:169
void AddToFrag1Female()
Definition: VolePopulationManager.h:216
int thisYear
Definition: VolePopulationManager.h:155
virtual void GeneticsResultsOutput(FILE *ofile, unsigned listindex)
Definition: VolePopulationManager.cpp:4145
int ListClosestMales(int p_x, int p_y, int p_steps)
Definition: VolePopulationManager.cpp:1928
int m_female3
Definition: VolePopulationManager.h:168
void AddToFrag3Female()
Definition: VolePopulationManager.h:220
int NoYoungKilledToday8
Definition: VolePopulationManager.h:282
virtual void LandscapeQuadrantOutputProbe(int a_day)
Definition: VolePopulationManager.cpp:3698
int m_geneticproductfertilityeffect
Definition: VolePopulationManager.h:285
Vole_MaleList MList
Definition: VolePopulationManager.h:226
void ResistanceOutput()
Resistance results file output
Definition: VolePopulationManager.cpp:4231
virtual void TheReallyBigOutputProbe()
Definition: VolePopulationManager.cpp:3814
Vole_Male * FindClosestMale(int p_x, int p_y, int p_steps)
Definition: VolePopulationManager.cpp:2686
VoleSummaryOutput * m_VoleRecordMort
Definition: VolePopulationManager.h:197
int YoungProducedToday
Definition: VolePopulationManager.h:281
void AddToYoung(int young)
Definition: VolePopulationManager.h:250
int SupplyGrowthStartDate()
Definition: VolePopulationManager.h:237
void AddToFrag2Male()
Definition: VolePopulationManager.h:217
int m_GrowthStartDate
Definition: VolePopulationManager.h:158
Vole_Male * FindWithinRadiusMale(int p_x, int p_y)
Definition: VolePopulationManager.cpp:2527
bool InSquare(int p_x, int p_y, int p_sqx, int p_sqy, int p_range)
Definition: VolePopulationManager.cpp:3230
Vole_Male * FindRandomMale()
Definition: VolePopulationManager.cpp:2880
void CreateObjects_Init(VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult *as, int number)
Definition: VolePopulationManager.cpp:3588
ofstream * m_VoleAgeSexLocationFile
Definition: VolePopulationManager.h:194
int YearsTotal
Definition: VolePopulationManager.h:155
void AddToFrag1Male()
Definition: VolePopulationManager.h:215
bool BarrierSearch(int F_x, int F_y, int M_x, int M_y)
Definition: VolePopulationManager.cpp:1261
virtual void Catastrophe()
Definition: VolePopulationManager.cpp:3630
vector< double > VoleHabitatBaseQualities
Definition: VolePopulationManager.h:172
int m_total1
Definition: VolePopulationManager.h:161
int SupplyHowManyVoles(unsigned p_x, unsigned p_y, unsigned p_size)
Definition: VolePopulationManager.cpp:1162
bool SupplyOlderFemales(unsigned p_x, unsigned p_y, unsigned p_Age, unsigned p_range)
Definition: VolePopulationManager.cpp:1015
void AddToYoungYr(int young)
Definition: VolePopulationManager.h:254
bool OpenSexRatiosProbe()
Definition: VolePopulationManager.cpp:3890
int m_female1
Definition: VolePopulationManager.h:160
int ListClosestFemales(int p_x, int p_y, int p_steps)
Definition: VolePopulationManager.cpp:2078
void SendMessage(TTypeOfVoleMessage p_message, unsigned p_x, unsigned p_y, unsigned p_range, bool p_sex, double p_Weight)
Definition: VolePopulationManager.cpp:3404
int NoYoungKilledToday
Definition: VolePopulationManager.h:282
virtual void TheAOROutputProbe()
Definition: VolePopulationManager.cpp:3758
void AddToFrag3Male()
Definition: VolePopulationManager.h:219
virtual void ImpactedProbe()
Definition: VolePopulationManager.cpp:523
bool RecordGeneticsToday(int p_today, int p_year, int p_start_year, int p_interval)
Definition: VolePopulationManager.cpp:1007
void CloseResistanceOutput()
Closes the output file ready for resistance results.
Definition: VolePopulationManager.cpp:4224
Vole_Female * FindClosestFemale(int p_x, int p_y, int p_steps)
Definition: VolePopulationManager.cpp:2227
int m_total2
Definition: VolePopulationManager.h:165
int ReproTable[4][12]
Definition: VolePopulationManager.h:221
TrapLineMap * m_Traplines
Definition: VolePopulationManager.h:171
virtual void TheSexRatiosProbe()
Definition: VolePopulationManager.cpp:3916
void ReproductionProbe()
Definition: VolePopulationManager.cpp:1254
FILE * SexRatiosPrb
Definition: VolePopulationManager.h:198
int NoYoungKilledToday4
Definition: VolePopulationManager.h:282
FILE * YoungsFile
Definition: VolePopulationManager.h:283
virtual void TheRipleysOutputProbe(FILE *a_prb)
Definition: VolePopulationManager.cpp:3763
int m_male1
Definition: VolePopulationManager.h:159
int NoYoungKilledToday9
Definition: VolePopulationManager.h:282
vector< Vole_Base * > * SupplyVoleList(unsigned x, unsigned y, unsigned range)
Definition: VolePopulationManager.cpp:3289
int m_male2
Definition: VolePopulationManager.h:163
void DoFirst()
Definition: VolePopulationManager.cpp:549
bool IsTrap(int p_x, int p_y)
Definition: VolePopulationManager.h:207
void TheAgeSexLocationProbe()
Definition: VolePopulationManager.cpp:3780
void OpenResistanceOutput()
Opens the output file ready for resistance results.
Definition: VolePopulationManager.cpp:4212
void CreateObjects(VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult *as, int number)
Definition: VolePopulationManager.cpp:3455
bool SuitableStartingLocation(int a_x, int a_y)
Definition: VolePopulationManager.cpp:460
void CloseSexRatiosProbe()
Definition: VolePopulationManager.cpp:3905
Vole_FemaleList FList
Definition: VolePopulationManager.h:224
uint32 GetVoleAllele(int a_list, int a_vole, int a_locus, int a_chromosome)
used to get a specific vole allele from outside the population manager
Definition: VolePopulationManager.h:200
virtual void Init(void)
Definition: VolePopulationManager.cpp:245
ofstream * m_VoleResistanceOutputFile
Definition: VolePopulationManager.h:195
void AddToJuvs(int juvs)
Definition: VolePopulationManager.h:255
int JuvsProducedToday
Definition: VolePopulationManager.h:281
AlleleFreq * AFreq
Definition: VolePopulationManager.h:280
void GeneticsOutputFile(unsigned listindex)
Definition: VolePopulationManager.cpp:4059
Vole_Population_Manager(Landscape *p_L)
Definition: VolePopulationManager.cpp:195
int m_female2
Definition: VolePopulationManager.h:164
A base class for summary outputs.
Definition: VolePopulationManager.h:123
virtual void OPrintEndl()
Definition: VolePopulationManager.cpp:4030
void CloseOutput()
Definition: VolePopulationManager.cpp:4038
void ResetData()
Definition: VolePopulationManager.cpp:4043
int m_ndDouble
Definition: VolePopulationManager.h:139
int m_ndInt
Definition: VolePopulationManager.h:138
ofstream * m_File
Definition: VolePopulationManager.h:136
VoleSummaryOutput(const char *a_filename, Landscape *a_land, int a_numdataINT, int a_numdataDOUBLE)
Definition: VolePopulationManager.cpp:3999
virtual void OPrint()
Definition: VolePopulationManager.cpp:4011
int m_dataI[100]
Definition: VolePopulationManager.h:140
virtual ~VoleSummaryOutput()
Definition: VolePopulationManager.cpp:4007
Landscape * m_landscape
Definition: VolePopulationManager.h:137
double m_dataD[100]
Definition: VolePopulationManager.h:141
void ChangeData(int a_data, int a_value)
Definition: VolePopulationManager.cpp:4048
void OpenOutput(const char *a_filename)
Definition: VolePopulationManager.cpp:4034
A struct for passing data to create a new vole.
Definition: vole_all.h:123
VoleObject
Definition: vole_all.h:99